;; Sri Ganeshji : Sri Balaji : Sri Pitreshwarji : Sri Durgaji : Sri Venkateshwara

/*
Objective(s) -
-	This code demonstrates the usage of Loop Collection
-	To view Stock Summary of a group company

Syntax -
-	There is an enhancement in syntax of attribute 'Collection' at definition 'Collection'.
-	[Collection : <CollectionName>
		Collection : <Data Collection Name>[:<Loop Collection Name>[:<Condition for Loop Coll>]]

Last Modification -
-	Altered on 13-01-2010

Specifications -
-	Would work only if a 'Group Company' is active
-	Member Companies should be maintained 'Accounts with Inventory' wise
*/

[Report: GrpCmpSSRep]

	Form 		: GrpCmpSSForm
	Variable	: SVCurrentCompany
	Repeat		: SVCurrentCompany
	Title		: "Group Company Stock Summary"
	
[Form: GrpCmpSSForm]
	
	Part		: GrpCmpSSPart
	Background  : @@SV_STOCKSUMMARY
		
[Part: GrpCmpSSPart]
	
	Lines 	: GrpCmpSSLineTitle, GrpCmpSSLineDetails
	Repeat	: GrpCmpSSLineDetails	: GrpCmpSSRepeatColl
	Scroll	: Vertical

	Common Border	: Yes
	
	[Line: GrpCmpSSLineTitle]
		
		Use		: GrpCmpSSLineDetails
		
		Local	: Field	: GrpCmpSSFldName		: Set as : "Particulars"
		Local	: Field	: GrpCmpSSFldClBalQty	: Set as : "Closing Qty"
		Local	: Field	: GrpCmpSSFldClBalRate	: Set as : "Closing Rate"
		Local	: Field	: GrpCmpSSFldClBalVal	: Set as : "Closing Value"
		
		Local	: Field	: Default			: Type	: String
		Local	: Field	: Default			: Align	: Centre
		Local	: Field	: Default			: Lines	: 0

		Border	: Top Thick Bottom Thin
		
	[Line: GrpCmpSSLineDetails]
		
		Fields		: GrpCmpSSFldName, GrpCmpSSFldClBal
		Repeat		: GrpCmpSSFldClBal
		Remove if	: $ClBalQty = 0

		[Field: GrpCmpSSFldName]
			
			Use				: Name Field
			Set as			: $StkName
			Quick Search	: Yes
			Style   		: Normal
			
		[Field: GrpCmpSSFldClBal]

			Fields	: GrpCmpSSFldClBalQty, GrpCmpSSFldClBalRate, GrpCmpSSFldClBalVal
			Border	: Thin Left
			
			[Field: GrpCmpSSFldClBalQty]
				
				Use		: Qty Field
				Set as	: $ClBalQty
				Width	: 15
				Style   : Small
				
			[Field: GrpCmpSSFldClBalRate]
				
				Use		: Rate Field
				Set as	: $ClBalRate
				Format	: "No Zero"
				Width	: 15
				Style   : Small
				
			[Field: GrpCmpSSFldClBalVal]
				
				Use		: Amount Field
				Set as	: $ClBalVal
				Width	: 15
				Style   : Small
				
;; Loop Collection

[Collection: GrpCmpSSRepeatColl]

	Source Collection	: GrpCmpSSLoopCollection
	By					: StkName	: $Name
	By					: UOM		: $BaseUnits
	Compute				: ClBalRate	: $ClosingValue/$ClosingBalance
	Aggr Compute		: ClBalQty	: SUM	: $ClosingBalance
	Aggr Compute		: ClBalVal	: SUM	: $ClosingValue
	Sort				: Default	: $StkName, $UOM

[Collection: GrpCmpSSLoopCollection]
	
	Collection	: StkColl	: GrpCmpColl
	
	[Collection: StkColl]
		
		Type	: Stock Item
		Fetch	: Name, BaseUnits, ClosingBalance, ClosingValue, ClosingRate
		
	[Collection: GrpCmpColl]
	
		Type	: Member List	: Company
		Child Of: ##SVCurrentCompany
		
;; End-of-File
